package com.wenx.unit2;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Objects;
import java.util.stream.IntStream;
import java.util.stream.Stream;

import static java.util.stream.Collectors.toList;

public class PathMain {
    public static void main(String[] args) throws IOException {

//        String[] words = new String[]{"jintian", "wo", "men", "de", "tian", "kong", "hen", "lan", "hen", "mei"};
//
//        Arrays.stream(words)
//                //.forEachOrdered(word -> System.out.println("word = " + word));
//                .map(word -> word.split(""))
//                .map(Arrays::stream)
//                .forEach(word -> System.out.println("word1 = " + word));
//
//        Arrays.stream(words)
//                .map(word -> word.split(""))
//                .flatMap(Arrays::stream)
//                .forEach(word -> System.out.println("word2 = " + word));

        //100内的勾股数
//        Stream<double[]> stream = IntStream.rangeClosed(1, 100).boxed()
//                .flatMap(i -> IntStream.rangeClosed(i,100).boxed()
//                        .map(j -> new double[]{i,j,Math.sqrt(i*i+j*j)}))
//                .filter(a -> a[2] % 1 == 0);
//        stream.forEach(a-> System.out.println("a = " + a[0] + ", "+a[1]+ ", "+a[2]));

        IntStream intStream = IntStream.of(1, 2, 3, 4, 5, 6, 6);
        Stream<String> stringStream = Stream.of("afew","focaf","oclfew");
        Stream<Object> empty = Stream.empty();

//        Path path = Paths.get("C:/Users/Administrator/Desktop/会计资料/1123演示问题.txt");
//        System.out.println(path.getFileName());
//        System.out.println(path.getFileSystem());
//        System.out.println(path.getRoot());
//        System.out.println(path.getNameCount());
//        Stream<String> strStream = Files.lines(path, Charset.defaultCharset());
//        strStream
//                .filter(line -> line.length()>0)
//                //.map(String::length)
//                .forEach(line -> System.out.println("line = " + line));

        Stream.iterate(0,n -> n+2).limit(10).forEach(System.out::print);

    }
}
